<template>
	<view class="page">
		<u-image show-loading :src="$imageOss(detail.image)" width="100%" height="248px" @click="preImage" />
		<view class="first">
			<SubTitle :label="detail.title" />
			<view class="addr">
				<view class="" style="margin-right: 6rpx;">
					<u-icon name="phone-fill" size="12" color="#909090"></u-icon>
				</view>
				<view class="" @tap.stop="callPhone">
					固定电话：{{detail.telphone}}
				</view>
			</view>
			<view class="addr">
				<view class="" style="margin-right: 6rpx;">
					<u-icon name="map-fill" size="12" color="#909090"></u-icon>
				</view>
				<view class="" @tap.stop="handleMap">
					{{detail.address}}
				</view>
			</view>
		</view>
		<view class="line">

		</view>
		<view class="body">
			<view class="navBox" style="">
				<view class="item" v-for="(i,index) in typeList" :key="index"
					:style="{color:(tabCurrent == index?'#000':'#909090')}" @tap.stop="tabChange(index)">
					<view class="leftIcon" :style="{background:(tabCurrent == index?'#466EC5':'#fff')}"></view>
					<view class="">
						{{i.name}}
					</view>
				</view>
			</view>
			<u-parse :content="detail.facilities" style="color: #909090;font-size: 26rpx;" v-if="tabCurrent == 1" />
			<u-parse :content="detail.msg" style="color: #909090;font-size: 26rpx;" v-if="tabCurrent == 0" />
			<view class="line" v-if="tabCurrent == 0"></view>

			<view class="remarkBox" v-if="tabCurrent == 0">
				<view class="" style="display: flex;justify-content: space-between;color: #000;font-size: 27rpx;">
					<view class="">活动室</view>
					<view class="" style="display: flex;">
						共<view class="" style="color: #466EC5;">
							{{detail.site?detail.site.length:0}}个
						</view>活动室
					</view>
				</view>
				<view class="orderItem" v-for="(i,index) in detail.site" :key="index">
					<image v-if="i.image" :src="$imageOss(i.image)" mode="aspectFill" style="" class="image"></image>
					<view class="content">
						<view class="" style="font-size: 28rpx;color: #000;">{{i.title}}</view>
						<view class="">{{i.tags}}</view>
						<view class="">免费</view>
					</view>
					<view class="right"
						@tap.stop="Jump(`/pages/home/stadiumNow?id=${i.id}&lat=${detail.lat}&lng=${detail.lng}&address=${detail.address}&Id=${detail.id}`)">
						预定
					</view>
				</view>
			</view>
			<view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<SubTitle label="评论" />
			</view>
			<remark :type_id="detail.id" :type="6" />
		</view>
		<view class="bott">
			<Foot  :comment="detail.count" :like="detail.like" :collect="detail.collect" :type="6"
				:is_like="detail.is_like" :is_collect="detail.is_collect" :is_id="detail.id" @like="handleLike"></Foot>
			<view class="button" style="background: #6B8BD0;" @tap.stop="callPhone"> 我要咨询 </view>
		</view>
	</view>
</template>

<script>
	import {
		venueDetail
	} from "@/request/homeApi.js";
	import Foot from "@/components/footer/index";
	import remark from "@/components/remark/index";
	export default {
		components: {
			remark,Foot
		},
		data() {
			return {
				tabCurrent: 0, // 当前大类
				typeList: [{
						name: "场馆详情",
						id: "0",
					},
					{
						name: "配套设施",
						id: "1",
					}
				],
				tabList: [],
				detail: {},

			};
		},
		onLoad(e) {
			this.getDetails(e.id);
		},
		computed: {
			// 是否已过期

		},
		// 监听页面滚动
		onPageScroll(scroll) {
			uni.$emit("onPageScroll", scroll.scrollTop);
		},
		methods: {
			// 点赞/收藏
			handleLike(v) {
				this.getDetails(v)
			},
			// tab 切换
			tabChange(e) {
				this.tabCurrent = e
			},
			Jump(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 预览图片
			preImage() {
				uni.previewImage({
					urls: [this.detail.cover_img],
				});
			},
			// 点击拨号
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.telphone,
				});
			},
			// 跳转地图
			handleMap() {
				const {
					lat,
					lng,
					address
				} = this.detail;


				wx.openLocation({
					latitude: lat,
					longitude: lng,
					address: address,
					scale: 16,
				});
				uni.navigateTo({
					url: `/pages/parse/map?lat=${lat}&lng=${lng}`
				});
			},
			// 获取详情
			getDetails(id) {
				venueDetail({
					id
				}).then((res) => {
					if (res.code == 200) {
						this.detail = res.data;
					}else{
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.page {
		.leftIcon {
			width: 6rpx;
			height: 30rpx;
			margin-right: 10rpx;
			background: #47578E;
		}

		.navBox {
			display: flex;
			justify-content: space-evenly;
			width: 50%;
			padding: 10rpx 0;
			box-sizing: border-box;
			font-size: 30rpx;

			.item {
				display: flex;
				align-items: center;
				width: 49.83% !important;
				text-align: left !important;
				padding: 10rpx 0;
			}
		}

		.bott {
			position: fixed;
			bottom: 0;
			left: 0;
			height: 110rpx;
			background: #fff;
			width: 100%;
			display: flex;
			align-items: center;
			padding: 30rpx 40rpx 40rpx;
			justify-content: space-between;
			box-shadow: 0 0 10rpx rgba(228, 228, 228, 0.5);
			box-sizing: border-box;
			z-index: 2;

			.button {
				width: 35%;
				height: 70rpx;
				padding: 0 28rpx;
				box-sizing: border-box;
				margin-left: 20rpx;
				text-align: center;
				line-height: 70rpx;
				color: #fff;
				font-size: 28rpx;
				background-color: $active-color;
				border-radius: 10rpx;
			}
		}

		.first {
			width: 94%;
			min-height: 100rpx;
			box-sizing: border-box;
			background-color: #ffffff;
			margin: 0rpx 24rpx 20rpx;

			.addr {
				display: flex;
				align-items: center;
				justify-content: flex-start;
				font-size: 26rpx;
				color: #909090;
				margin-bottom: 10rpx;
			}

		}

		.line {
			width: 100%;
			height: 12rpx;
			background: #D9D9D999;
		}

		.body {
			width: 94%;
			// padding: 20rpx 24rpx;
			min-height: 100rpx;
			box-sizing: border-box;
			background-color: #ffffff;
			margin-top: -14rpx;
			padding-bottom: 140rpx;
			margin: 0 24rpx;

			.line {
				width: 100%;
				height: 2rpx;
				background: #D9D9D999;
				margin: 20rpx 0;
			}

			.tabBox {
				width: 100%;
				box-sizing: border-box;
				font-size: 30rpx;

				.navItem {
					padding: 10rpx 20rpx 0;
					width: 24.33%;
					text-align: center;
					box-sizing: border-box;

					.image {
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
					}
				}
			}

			.remarkBox {
				width: 100%;
				box-sizing: border-box;
				font-size: 28rpx;
				color: #909090;

				.orderItem {
					width: 98%;
					text-align: left;
					box-sizing: border-box;
					display: flex;
					margin: 20rpx auto;
					align-items: center;

					.right {
						width: 8%;
						background: #47578E;
						color: #fff;
						padding: 38rpx 14rpx;
						font-size: 26rpx;
						height: 100%;
						border-bottom-right-radius: 10rpx;
						border-top-right-radius: 10rpx;
						text-align: center;
					}

					.content {
						width: 64%;
						font-size: 23rpx;
						color: #909090;

						view {
							height: 38rpx;
							line-height: 38rpx;
						}

					}

					.image {
						width: 160rpx;
						height: 110rpx;
						border-radius: 10rpx;
						margin-right: 16rpx;
					}
				}

				.navItem {
					width: 98%;
					text-align: center;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					margin: 20rpx auto;

					.image {
						width: 56rpx;
						height: 56rpx;
						border-radius: 50%;
						margin-right: 16rpx;
					}
				}
			}
		}
	}
</style>
